package com.logistics.modules.transportationManagement.controller;

import java.util.Arrays;
import java.util.Map;

import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import com.logistics.modules.transportationManagement.entity.VehiclemoveorderEntity;
import com.logistics.modules.transportationManagement.service.VehiclemoveorderService;
import com.logistics.common.utils.PageUtils;
import com.logistics.common.utils.R;



/**
 * 
 *
 * @author HURRICANE
 * @email HURRICANE@nb.com
 * @date 2022-05-06 18:12:10
 */
@RestController
@RequestMapping("transportationManagement/vehiclemoveorder")
public class VehiclemoveorderController {
    @Autowired
    private VehiclemoveorderService vehiclemoveorderService;

    /**
     * 列表
     */
    @RequestMapping("/list")
    @RequiresPermissions("transportationManagement:vehiclemoveorder:list")
    public R list(@RequestParam Map<String, Object> params){

        PageUtils page = vehiclemoveorderService.queryPage(params);

        return R.ok().put("page", page);
    }

    /**
     * 实现入库操作
     */
    @RequestMapping("/ruku")
    @RequiresPermissions("transportationManagement:vehiclemoveorder:save")
    public R ruku(@RequestBody Map<String, Object> params){

        // 完成入库操作
        vehiclemoveorderService.ruku(params);

        return R.ok();
    }

    /**
     * 为车辆订单添加总里程
     */
    @RequestMapping("/addTotalMileage")
    @RequiresPermissions("transportationManagement:vehiclemoveorder:update")
    public R addTotalMileage(@RequestBody Map<String, Object> params){

        // 完成添加总里程操作
        vehiclemoveorderService.addTotalMileage(params);

        return R.ok();
    }

    /**
     * 查询 根据 状态
     */
    @RequestMapping("/listByStatus")
    @RequiresPermissions("transportationManagement:vehiclemoveorder:list")
    public R listByStatus(@RequestParam Map<String, Object> params){

        PageUtils page = vehiclemoveorderService.queryPageListByStatus(params);

        return R.ok().put("page", page);
    }

    /**
     * 修改车辆运输状态和运输计划状态
     *
     * @param params 参数个数
     * @return {@link R}
     */
    @RequestMapping("/updateVehicleAndMoveOfStatus")
    @RequiresPermissions("transportationManagement:vehiclemoveorder:update")
    public R updateVehicleAndMoveOfStatus(@RequestParam Map<String, Object> params) {

        // 修改车辆运输状态和运输计划状态
        vehiclemoveorderService.updateVehicleAndMoveOfStatus(params);

        return R.ok();
    }


    /**
     * 生成运输订单
     *
     * @param params 参数个数
     * @return {@link R}
     */
    @RequestMapping("/generateShippingOrder")
    @RequiresPermissions("transportationManagement:vehiclemoveorder:save")
    public R generateShippingOrder(@RequestParam Map<String, Object> params){

        // 生成运输订单
        vehiclemoveorderService.generateShippingOrder(params);

        return R.ok();
    }


    /**
     * 信息
     */
    @RequestMapping("/info/{id}")
    @RequiresPermissions("transportationManagement:vehiclemoveorder:info")
    public R info(@PathVariable("id") Integer id){

		VehiclemoveorderEntity vehiclemoveorder = vehiclemoveorderService.getById(id);

        return R.ok().put("vehiclemoveorder", vehiclemoveorder);
    }

    /**
     * 保存
     */
    @RequestMapping("/save")
    @RequiresPermissions("transportationManagement:vehiclemoveorder:save")
    public R save(@RequestBody VehiclemoveorderEntity vehiclemoveorder){

		vehiclemoveorderService.save(vehiclemoveorder);

        return R.ok();
    }

    /**
     * 修改
     */
    @RequestMapping("/update")
    @RequiresPermissions("transportationManagement:vehiclemoveorder:update")
    public R update(@RequestBody VehiclemoveorderEntity vehiclemoveorder){

		vehiclemoveorderService.updateById(vehiclemoveorder);

        return R.ok();
    }

    /**
     * 删除
     */
    @RequestMapping("/delete")
    @RequiresPermissions("transportationManagement:vehiclemoveorder:delete")
    public R delete(@RequestBody Integer[] ids){

		vehiclemoveorderService.removeByIds(Arrays.asList(ids));

        return R.ok();
    }

    /**
     * 获取统计数据
     */
    @RequestMapping("/getStatisticsData")
    @RequiresPermissions("transportationManagement:vehiclemoveorder:list")
    public R getStatisticsData(){
        // 获取统计数据
        return vehiclemoveorderService.getStatisticsData();
    }

    /**
     * 获取统计数据 年
     */
    @RequestMapping("/getStatisticsDataByYear")
    @RequiresPermissions("transportationManagement:vehiclemoveorder:list")
    public R getStatisticsDataByYear(){
        // 获取统计数据
        return vehiclemoveorderService.getStatisticsDataByYear();
    }

}
